from decimal import Decimal, ROUND_HALF_UP

import yaml


def get_data(path,cal, num):
    """
    读取yaml文件
    :return:
    """
    with open(path, encoding='utf-8') as f:
        datas = yaml.safe_load(f)
        add_datas = datas.get(cal)
        return (add_datas.get(num).get("datas"), add_datas.get(num).get("ids"))


def chang_to_decimal(num):
    """
    使用decimal转的字符串转换成数字
    :param num:
    :return:
    """
    return Decimal(f"{num}").quantize(Decimal('0.00'), rounding=ROUND_HALF_UP)
# def getData(filename):
#     with open(filename, encoding='utf-8') as f:
#         return yaml.safe_load(f)
#
#
# def getDatas(datas, cal, num):
#     add_datas = datas.get(cal)
#     return (add_datas.get(num).get("datas"), add_datas.get(num).get("ids"))
